﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MySql.Data.MySqlClient;
using System.Data;

namespace Data
{
    internal class DBOperation
    {
        private MySqlCommand _command;
        private string _statement;
        private List<MySqlParameter> _parameters;

        protected MySqlCommand Command
        {
            get { return _command; }
        }
        protected string Statement
        {
            get { return _statement; }
            set { _statement = value; }
        }
        protected List<MySqlParameter> Parameters
        {
            get { return _parameters; }
            set { _parameters = value; }
        }

        protected DBOperation(string statement, List<MySqlParameter> parameters)
        {
            _command = new MySqlCommand() { CommandType = CommandType.Text, Connection = DBH.GetConnection() };
            Statement = statement;
            Parameters = parameters;
        }

        protected void Bind()
        {
            _command.CommandText = _statement;
            _parameters.ForEach(p => _command.Parameters.Add(p));
        }
    }
}
